//
//  JPEmotionButton.swift
//  JPWeibo
//
//  Created by 哇咔咔 on 2016/10/6.
//  Copyright © 2016年 jp. All rights reserved.
//

import UIKit

class JPEmotionButton: UIButton {
    
    var emotion: JPEmotion? {
        didSet {
            
            self.isHidden = false
            
            if emotion?.type == "0" {
                self.setImage(UIImage.init(named: (emotion?.path!)!), for: .normal)
                self.setTitle(nil, for: .normal)
            }else {
                self.setTitle(((emotion?.code)! as NSString).emoji(), for: .normal)
                self.setImage(nil, for: .normal)
            }
            
            
        }
    }
    

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }

    private func setupUI() {
//        self.backgroundColor = RandomColor()
    }
}
